<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改保证金支付')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: jasny-bootstrap-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
	<style>
		.file-preview {
		    padding: 0;
		    margin-bottom: 0;
		    border-radius: 0;
		    border: none;
		}
		
		.krajee-default.file-preview-frame {
		    margin-right: 20px;
		    padding: 0;
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default.file-preview-frame:not(.file-preview-error):hover {
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default .file-footer-caption {
			margin-bottom: 0;
		}
		
		.krajee-default.file-preview-frame .file-thumbnail-footer {
		    height: auto;
		}
		
		.krajee-default .file-caption-info {
			width: auto;
		}
		
		.kv-upload-progress .progress {
			margin-top: 0;
		}
		
		.krajee-default.file-preview-frame .kv-file-content,
		.krajee-default .file-size-info,
		.krajee-default .file-upload-indicator,
		.file-input .kv-file-upload,
		.file-input .kv-file-zoom {
			display: none;
		}
		
		.file-input .kv-file-remove {
			position: absolute;
			top: 3px;
			right: -15px;
			height: 14px;
			padding: 0;
			margin: 0;
			border: none;
			background: none;
		}
		
		.file-input .kv-file-remove:active, 
		.file-input .kv-file-remove:focus {
			background: none;
			outline: none;
			box-shadow: none;
		}
		
		.file-input .kv-file-remove .glyphicon-trash {
			color: red;
		}
	</style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-bszbzfd-edit" th:object="${gcBszbzfd}" enctype="multipart/form-data" method="post">
        	<h4 class="form-header h4">基本信息</h4>
            <input name="id" th:field="*{id}" type="hidden">
            <input type="hidden" id="zilwj" name="zilwj" th:value="*{zilwj}" />
            <input name="gcProjectid" type="hidden" th:field="*{gcProjectid}" />
            <input type="hidden" name="owner" th:field="*{owner}" />
        	<input type="hidden" name="ownerId" th:field="*{ownerId}" />
        	<input type="hidden" id="approvename" name="approvename" th:value="${approvename}" />
        	<div class="form-group">   
            	<label class="col-sm-1 control-label is-required">项目名称：</label>
                <div class="col-sm-2">
                    <input name="gcProjectname" th:field="*{gcProjectname}" class="form-control" type="text" autoComplete="off" required readonly="readonly">
                </div>
                <label class="col-sm-1 control-label is-required">收款单位：</label>
                <div class="col-sm-2">
                    <select id="skdw" th:field="*{skdw}" name="skdw" class="form-control" required>
						<option th:each="cl:${clis}" th:value="${cl.name}" th:text="${cl.name}"></option>
					</select>
                </div>
                <label class="col-sm-1 control-label is-required">申请人：</label>
                <div class="col-sm-2">
                    <input name="fksqr" th:field="*{fksqr}" class="form-control" type="text" autoComplete="off" readonly="readonly" required>
                </div>
                <label class="col-sm-1 control-label is-required">报销部门：</label>
                <div class="col-sm-2">
                    <input name="dept" class="form-control" type="text" th:field="*{dept}" autoComplete="off" readonly="readonly" required>
                    <input name="deptId" th:field="*{deptId}" type="hidden">
                </div>
            </div>
            <div class="form-group">    
            	<label class="col-sm-1 control-label is-required">项目所属：</label>
                <div class="col-sm-2">
                    <select name="authority" th:field="*{authority}" class="form-control" required>
						<option th:each="cl:${deptlis}" th:value="${cl.deptId}" th:text="${cl.deptName}"></option>
					</select>
                </div>
                <label class="col-sm-1 control-label is-required">付款单位：</label>
            	<div class="col-sm-2">
            		<select name="ztdw" th:field="*{ztdw}" class="form-control" th:with="type=${@dict.getType('sj_gongs')}" required>
                    	<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                	</select>
                </div>
            </div>
            <div class="form-group">
            	<label class="col-sm-1 control-label is-required">证明人：</label>
                <div class="col-sm-2">
                	<div class="input-group">
                    	<input id="zmr" th:field="*{zmr}" class="form-control" type="hidden">
                    	<input id="zmrId" th:field="*{zmrId}" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel1()" id="zmrStr" th:value="*{zmr}" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
                <label class="col-sm-1 control-label is-required">会计复核：</label>
                <div class="col-sm-2">
                	<div class="input-group">
                    	<input id="hj" th:field="*{hj}" class="form-control" type="hidden">
                    	<input id="hjId" th:field="*{hjId}" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel2()" id="hjStr" th:value="*{hj}" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
            	<label class="col-sm-1 control-label is-required">副总审批1：</label>
                <div class="col-sm-2">
                	<div class="input-group">
                    	<input id="fzjl1" th:field="*{fzjl1}" class="form-control" type="hidden">
                    	<input id="fzjl1Id" th:field="*{fzjl1Id}" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel3()" id="fzjl1Str" th:value="*{fzjl1}" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
                <label class="col-sm-1 control-label is-required">副总审批2：</label>
                <div class="col-sm-2">
                	<div class="input-group">
                    	<input id="fzjl2" th:field="*{fzjl2}" class="form-control" type="hidden">
                    	<input id="fzjl2Id" th:field="*{fzjl2Id}" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel4()" id="fzjl2Str" th:value="*{fzjl2}" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
            </div>
            <div class="form-group">
            	<label class="col-sm-1 control-label is-required">总经理：</label>
                <div class="col-sm-2">
                	<div class="input-group">
                    	<input id="zjl" th:field="*{zjl}" class="form-control" type="hidden">
                    	<input id="zjlId" th:field="*{zjlId}" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel5()" id="zjlStr" th:value="*{zjl}" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
                <label class="col-sm-1 control-label is-required">出纳：</label>
                <div class="col-sm-2">
                	<div class="input-group">
                    	<input id="cn" th:field="*{cn}" class="form-control" type="hidden">
                    	<input id="cnId" th:field="*{cnId}" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel6()" id="cnStr" th:value="*{cn}" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">资料文件：</label>
                <div class="col-sm-11" style="margin-top: 8px;" id="zlwjlink">
                </div>
            </div>
            <div class="form-group">
	            <label class="col-sm-1 control-label font-noraml">资料文件：</label>
	            <div class="col-sm-11">
	            	<div class="file-loading">
		            	<input id="multipleFile" name="files" type="file" multiple>
		        	</div>
	            </div>
            </div>
            <h4 class="form-header h4">表单项</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>
                    <div class="col-sm-12 select-table table-striped">
					    <table id="bootstrap-table"></table>
					</div>
                </div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <script th:src="@{/ruoyi/base64.min.js?v=20231208}"></script>
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: bootstrap-suggest-js" />
    <th:block th:include="include :: bootstrap-typeahead-js" />
    <script th:src="@{/js/jquery.tmpl.js}"></script>
    <script th:inline="javascript">
        var prefix = ctx + "gcgl/bszbzfd";
        $("#form-bszbzfd-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.saveTab(prefix + "/edit", $('#form-bszbzfd-edit').serialize());
            }
        }

        $(function() {
        	var data = [[${gcBszbzfd.gcBszbzfditem}]];
	    	// 初始化数据, 可以由后台传过来
		    var options = {
		    	data: data,
                pagination: false,
		        showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
		        columns: [
		        {
		        	field: 'index',
		        	align: 'center',
		        	title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	var columnId = $.common.sprintf("<input type='hidden' name='gcBszbzfditem[%s].xuh' value='%s'>", index, row.id);
                    	return columnIndex + $.table.serialNumber(index) + columnId;
                    }
                },
		        {
		            field: 'descs',
		            align: 'center',
		            title: '支付事项摘要说明',
		            formatter: function(value, row, index) {
		            	var html = $.common.sprintf("<input class='form-control itemdescs' type='text' autoComplete='off' name='gcBszbzfditem[%s].descs' value='%s'>", index, value);
		        		return html;
                    }
		        },
// 		        {
// 		            field: 'type',
// 		            align: 'center',
// 		            title: '支付方式',
// 		            width:180,
// 		            formatter: function(value, row, index) {
// 		        		var data = [{ index: index, type: value }];
// 		                return $("#itemType").tmpl(data).html();
//                     }
// 		        },
		        {
		            field: 'jine',
		            align: 'center',
		            title: '支付金额',
		            width:180,
		            formatter: function(value, row, index) {
		            	var html = $.common.sprintf("<input class='form-control itemjine' type='text' autoComplete='off' name='gcBszbzfditem[%s].jine' value='%s'>", index, value);
		        		return html;
                    }
		        },
		        {
		            field: 'memo',
		            align: 'center',
		            title: '备注',
		            width:360,
		            formatter: function(value, row, index) {
		            	var html = $.common.sprintf("<input class='form-control' type='text' autoComplete='off' name='gcBszbzfditem[%s].memo' value='%s'>", index, value);
		        		return html;
                    }
		        },
		        {
                    title: '操作',
                    align: 'center',
                    width:180,
                    formatter: function(value, row, index) {
                    	var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delColumnByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
                    }
                }]
		    };
		    $.table.init(options);
		    
		    
			var zilwj = $("#zilwj").val();
        	
        	var n=zilwj.split(",");
        	for(var i=0;i<n.length;i++){
//         		var url = "http://lkgnews.cn:8012/onlinePreview?url="+encodeURIComponent(Base64.encode(n[i]));
        		var url = n[i];
        		$("#zlwjlink").append("<a href='"+url+"' target='_blank' >"+n[i]+"</a><br>");
        	}
        	
        	// 多图上传
	       $("#multipleFile").fileinput({
	           uploadUrl: "/gcgl/bszbzfd/uploads",
	           uploadAsync: false,
	           showClose: false,
	           showCancel: false,
	           dropZoneEnabled: false,
	           buttonLabelClass: ''
	       }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
	       	var rsp = data.response;
	           log.info("reutrn fileNames：" + rsp.fileNames)
			   $("#zilwj").val(rsp.fileNames);
	       }).on('fileremoved', function (event, id, index) {
	           $("input[name='" + event.currentTarget.id + "']").val('')
	       })
		});
        
        $.validator.addMethod("itemtype", function(value, element) {
            return !this.optional(element);
        }, "支付方式必填。");
        $.validator.addMethod("itemdescs", function(value, element) {
            return !this.optional(element);
        }, "支付事项摘要说明必填。");
        $.validator.addMethod("itemjine", function(value, element) {
            return !this.optional(element) && (value <= 10000000 && value >= 1);
        }, "支付金额长度区间1-10000000。");
        
        function addRow() {
        	var count = $("#" + table.options.id).bootstrapTable('getData').length;
        	var row = {
                index: $.table.serialNumber(count),
                descs: "",
                type: "",
                jine: "",
                memo: ""
            }
        	sub.addColumn(row);
        }
        
      //-----------------------
        //选择用户level1
		function selectlevel1() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel1User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel1User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#zmrId").val(rows[0].userId);
            $("#zmr").val(rows[0].userName);
            $("#zmrStr").val(rows[0].userName);
            $.modal.closeAll();
        }
		
		//选择用户level2
		function selectlevel2() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel2User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel2User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#hjId").val(rows[0].userId);
            $("#hj").val(rows[0].userName);
            $("#hjStr").val(rows[0].userName);
            $.modal.closeAll();
        }
		
		//选择用户level3
		function selectlevel3() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel3User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel3User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#fzjl1Id").val(rows[0].userId);
            $("#fzjl1").val(rows[0].userName);
            $("#fzjl1Str").val(rows[0].userName);
            $.modal.closeAll();
        }
		
		//选择用户level4
		function selectlevel4() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel4User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel4User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#fzjl2Id").val(rows[0].userId);
            $("#fzjl2").val(rows[0].userName);
            $("#fzjl2Str").val(rows[0].userName);
            $.modal.closeAll();
        }
		
		//选择用户level5
		function selectlevel5() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel5User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel5User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#zjlId").val(rows[0].userId);
            $("#zjl").val(rows[0].userName);
            $("#zjlStr").val(rows[0].userName);
            $.modal.closeAll();
        }
		
		//选择用户level6
		function selectlevel6() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel6User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel6User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#cnId").val(rows[0].userId);
            $("#cn").val(rows[0].userName);
            $("#cnStr").val(rows[0].userName);
            $.modal.closeAll();
        }
    </script>
</body>
</html>

<!-- 成本类型 -->
<script id="itemType" type="text/x-jquery-tmpl">
<div>
<select class='form-control' name='gcBszbzfditem[${index}].type'>
    <option value="电汇" {{if type==="电汇"}}selected{{/if}}>电汇</option>
<option value="现金" {{if type==="现金"}}selected{{/if}}>现金</option>
<option value="承兑" {{if type==="承兑"}}selected{{/if}}>承兑</option>
<option value="转账" {{if type==="转账"}}selected{{/if}}>转账</option>
<option value="其他" {{if type==="其他"}}selected{{/if}}>其他</option>
</select>
</div>
</script>